package com.demo.action;



import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.demo.formbean.UserForm;
import com.demo.service.LoginService;
import com.demo.serviceImpl.LoginServiceImpl;
import com.demo.vo.UserVo;


import struts.config.Action;
import struts.config.Namespace;
import struts.config.Result;
import struts.config.Results;
import struts.form.ActionForm;

@Namespace(value="/test")
@Results({@Result(name="success",value="/index.jsp"),
	@Result(name="fail", value = "/view/fail.jsp")})
public class LoginAction implements struts.action.Action{

	
	@Action(value="/LogionAction.action",restults={@Result(name="success",value="/view/success.jsp")})
	public String login(HttpServletRequest request,HttpServletResponse response,UserForm userForm) {
		LoginService loginService=new LoginServiceImpl();
		UserVo user=loginService.loginValidate(userForm.getUsername(), userForm.getPassword());
		request.setAttribute("User", user);
		return user.getMsg();
		
	}

	@Action(value="/LogionActions.action")
	public String execute() {
		return "fail";
	}

}
